import { IToolTipItem } from "../../../../../com/mui/manager/IToolTipItem";
import { SWFPlayer } from "../../../scene/modle/SWFPlayer";
import { ActionType } from "../../../scene/modle/data/ActionType";
import { AcupointConfig } from "../../../resource/AcupointConfig";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { ModelType } from "../../../scene/modle/data/ModelType";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { LookupPlayerData } from "../LookupPlayerData";
import { Cache } from "../../../cache/Cache";
import { ColorConfig } from "../../../resource/ColorConfig";
import { Language } from "../../../../../extend/language/Language";
import { ToolTipInfo } from "../../../model/ToolTipInfo";
import { NormalTooltip } from "../../common/tooltip/NormalTooltip";
import { AcupointData } from "./AcupointData";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
type int = number;
//class AcupointRootTarget
    
    export  class AcupointRootTarget /* flash.display.Sprite */ implements IToolTipItem
    {
        

        public set mode(arg1: string)
        {
            this._mode = arg1;
            return;
        }

        /* internal  */loadBournSWFComplete(arg1: SWFPlayer): void
        {
            this._targetSwf.updateFrame(ActionType.Stand, 1, true);
            this._targetSwf.updateCurrentFrame(0);
            this._targetSwf.play();
            return;
        }

        public updateInfo(arg1: int, arg2: Boolean=false): void
        {
            var loc2=0;
            var loc8=0;
            var loc1=AcupointConfig.instance.getRootTargetIndex(arg1);
            if (this._bitmap && this._bitmap.parent) 
            {
                removeChild(this._bitmap);
            }
            this.dispose();
            if (arg1 == 0) 
            {
                if (!this._bitmap) 
                {
                    this._bitmap = new Object /* flash.display.Bitmap */();
                }
                this._bitmap.x = 0;
                this._bitmap.y = 0;
                addChild(this._bitmap);
                this._bitmap.filters = [FilterConst.colorFilter];
                LoaderHelp.addResCallBack(ResFileConst.breakThrough, this.onResLoaded);
            }
            else 
            {
                if (this._targetSwf == null) 
                {
                    this._targetSwf = new SWFPlayer();
                }
                this._targetSwf.loadComplete = this.loadBournSWFComplete;
                this._targetSwf.load("RootTarget_" + loc1 + ".swf", ModelType.NormalSwf, null);
                addChild(this._targetSwf);
                this._targetSwf.move(35, 15);
            }
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other) 
                {
                    loc2 = LookupPlayerData.miniPlayer.careerEnable;
                }
            }
            else 
            {
                loc2 = Cache.instance.role.entityInfo.careerEnable;
            }
            var loc3=AcupointConfig.instance.getRootTargetByCareerAndLevel(loc2, arg1);
            var loc4=AcupointConfig.instance.getNextRootTargetByCareerAndLevel(loc2, arg1);
            var loc5="";
            var loc6=[];
            var loc7=[];
            var loc9=ColorConfig.instance.getItemColorString(4);
            if (arg1 == 0) 
            {
                if (loc3 != null) 
                {
                    loc8 = this.getNextBournNum(loc3.level);
                    loc5 = (loc5 = "") + "<font size=\'14\'><font color=\'" + loc9 + "\'>" + Language.getStringByParam(30208, loc3.level) + "<font color=\'#00ff00\'>（<font color=\'#ff0000\'>" + loc8 + "</font>/8）</font></font>\n" + "<font color=\'#7c7c7c\'><textFormat leading=\'3\'>" + loc3.descStr + "</textFormat>\n\n</font>";
                    loc6.push(loc5);
                    loc7.push(loc1);
                }
            }
            else 
            {
                if (!(loc4 == null) && !arg2) 
                {
                    loc8 = this.getNextBournNum(loc4.level);
                    loc5 = loc5 + "<font size=\'14\'><font color=\'" + loc9 + "\'>" + Language.getStringByParam(30208, loc4.level) + "</font>" + "<font color=\'#00ff00\'>（<font color=\'#ff0000\'>" + loc8 + "</font>/8）</font></font>\n" + "<font color=\'#7c7c7c\'><textFormat leading=\'3\'>" + loc4.descStr + "</textFormat>\n\n</font>";
                    loc6.push(loc5);
                    loc7.push(loc1 + 1);
                }
                if (loc3 != null) 
                {
                    loc5 = "";
                    if (arg2) 
                    {
                        loc5 = loc5 + "<font size=\'14\'><font color=\'" + loc9 + "\'>" + Language.getStringByParam(30208, arg1) + "</font></font>\n" + "<font color=\'#F1FFB1\'><textFormat leading=\'3\'>" + loc3.descStr + "</textFormat>\n\n</font>";
                    }
                    else 
                    {
                        loc5 = loc5 + "<font size=\'14\'><font color=\'" + loc9 + "\'>" + Language.getStringByParam(30208, arg1) + "</font>" + "<font color=\'#00ff00\'>" + Language.getString(30112) + "</font></font>\n" + "<font color=\'#F1FFB1\'><textFormat leading=\'3\'>" + loc3.descStr + "</textFormat>\n\n</font>";
                    }
                    loc6.push(loc5);
                    loc7.push(loc1);
                }
            }
            loc5 = (loc5 = "") + Language.getString(30209);
            loc6.push(loc5);
            var loc10=[loc6, loc7];
            var loc11=new ToolTipInfo(NormalTooltip.ToolTipRenderType_RootTarget, loc10);
            this.toolTipData = loc11;
            return;
        }

        /* internal  */getNextBournNum(arg1: int): int
        {
            var loc1=0;
            var loc3=0;
            var loc2=new Map<any, any> /* flash.utils.Dictionary */();
            if (this._mode != GModuleEvent.Mode_Self) 
            {
                if (this._mode == GModuleEvent.Mode_Other) 
                {
                    if (LookupPlayerData.acupointInfo) 
                    {
                        loc2 = LookupPlayerData.acupointInfo.roots;
                    }
                }
            }
            else if (AcupointData.acupointInfo) 
            {
                loc2 = AcupointData.acupointInfo.roots;
            }
            var loc4=0;
            var loc5=loc2;
            for(loc3 of loc5) 
            {
                if (!(loc3 >= arg1)) 
                {
                    continue;
                }
                loc1 = loc1 + 1;
            }
            return loc1;
        }

        /* internal  */onResLoaded(): void
        {
            this._bitmap.bitmapData = GlobalClass.getBitmapData(ImagesConst.RootTarget);
            return;
        }

        public get toolTipData()
        {
            return this._toolTipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._toolTipData = arg1;
            return;
        }

        public dispose(): void
        {
            if (this._targetSwf) 
            {
                this._targetSwf.stop();
                this._targetSwf.dispose();
            }
            return;
        }

        /* internal */ /* var */_mode: string="自己";

        /* internal */ /* var */_bitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_targetSwf: SWFPlayer;

        protected /* var */_toolTipData;
    }
